﻿using guidHelper;
using Microsoft.AspNetCore.Mvc;
using MyDapperApi.Models;
using MyDapperApi.Services;
using QYWXUpdate.DataModel;
using QYWXUpdate.DataModel.CheckInfo;

namespace MyDapperApi.Controllers;

[ApiController]
[Route("api/[controller]")]
public class JwtTokenController : ControllerBase
{
    private readonly IJwtTokenService _tokenService;

    public JwtTokenController(IJwtTokenService tokenService)
    {
        _tokenService = tokenService;
    }
    /// <summary>
    /// 创建后台jwt token的接口-不对外使用
    /// </summary>
    /// <returns></returns>
    [HttpPost("CreateToken")]
    public IActionResult GetAll()
    {
        var token = _tokenService.CreateToken();
        return Ok(token);
    }
    /// <summary>
    /// 检查这个token是否还在有效期内
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [HttpPost("CheckToken")]
    public IActionResult CheckToken(IdRequest request)
    {
        var res = _tokenService.CheckToken(request);
        return Ok(res);
    }
}